﻿<UserControl
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  xmlns:local="clr-namespace:iTuner"
  xmlns:resx="clr-namespace:iTuner.Properties"
  x:Class="iTuner.RatingControl"
  x:ClassModifier="internal"
  Width="60" Height="11">

  <UserControl.Resources>
    <Style TargetType="{x:Type ToggleButton}">
      <Setter Property="Cursor" Value="Hand" />
      <Setter Property="Focusable" Value="False" />
      <Setter Property="Template">
        <Setter.Value>
          <ControlTemplate TargetType="{x:Type ToggleButton}">
            <Grid>
              <Viewbox Name="dotTemplate">
                <Border Height="12" Width="12" Background="Transparent">
                  <Ellipse Height="3" Width="3" Fill="Gray"/>
                </Border>
              </Viewbox>
              <Viewbox Name="starTemplate" Visibility="Hidden">
                <Path Fill="#505050" Data="F1 M 145.637,174.227L 127.619,110.39L 180.809,70.7577L 114.528,68.1664L 93.2725,5.33333L 70.3262,67.569L 4,68.3681L 56.0988,109.423L 36.3629,172.75L 91.508,135.888L 145.637,174.227 Z"/>
              </Viewbox>
            </Grid>
            <ControlTemplate.Triggers>
              <Trigger Property="IsChecked" Value="True">
                <Setter TargetName="dotTemplate" Property="Visibility" Value="Hidden" />
                <Setter TargetName="starTemplate" Property="Visibility" Value="Visible" />
              </Trigger>
            </ControlTemplate.Triggers>
          </ControlTemplate>
        </Setter.Value>
      </Setter>
    </Style>
  </UserControl.Resources>

  <Grid>
    <Grid.ColumnDefinitions>
      <ColumnDefinition/>
      <ColumnDefinition/>
      <ColumnDefinition/>
      <ColumnDefinition/>
      <ColumnDefinition/>
    </Grid.ColumnDefinitions>

    <ToggleButton
      x:Name="button1" Grid.Column="0" Tag="20"
      ToolTip="{x:Static resx:Resources.RatingControl_1Star}"
      Click="RatingButtonClickEventHandler"/>
    <ToggleButton
      x:Name="button2" Grid.Column="1" Tag="40"
      ToolTip="{x:Static resx:Resources.RatingControl_2Stars}"
      Click="RatingButtonClickEventHandler"/>
    <ToggleButton
      x:Name="button3" Grid.Column="2" Tag="60"
      ToolTip="{x:Static resx:Resources.RatingControl_3Stars}"
      Click="RatingButtonClickEventHandler"/>
    <ToggleButton
      x:Name="button4" Grid.Column="3" Tag="80"
      ToolTip="{x:Static resx:Resources.RatingControl_4Stars}"
      Click="RatingButtonClickEventHandler"/>
    <ToggleButton
      x:Name="button5" Grid.Column="4" Tag="100"
      ToolTip="{x:Static resx:Resources.RatingControl_5Stars}"
      Click="RatingButtonClickEventHandler"/>
  </Grid>
</UserControl>
